package com.soft.app.ruanba;

import java.util.concurrent.LinkedBlockingQueue;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.soft.webharvest.util.ConfigFactory;

public class ImgToDownload {
	private static final Logger log = LoggerFactory.getLogger(ImgToDownload.class);
	public static final String CONFIG = "ruanba.properties";
	public static final String APPCODE = "ruan";
	public static boolean local;
	public static boolean running;
	public static String prefix;
	
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		ConfigFactory.Config cconfig = ConfigFactory.getConfig("ruanba.properties");
		String imgFileDir = cconfig.getProperty((new StringBuilder()).append(prefix).append("imgFileDir").toString());
		String xmlFileDir = cconfig.getProperty((new StringBuilder()).append(prefix).append("xmlFileDir").toString());
		String xmlFile = null;
		ImgDownloadJob job = null;
		for(int i = 1; i < 10; i++){
			xmlFile = String.format("%s\\ruan8_cate_%d.xml", xmlFileDir, i);
			job = new ImgDownloadJob(imgFileDir, xmlFile);
			job.excute();
		}
		if (org.apache.commons.lang.StringUtils.isBlank(imgFileDir))
		{
			log.info("downloadFileDir is null");
			System.exit(-1);
		}
	}
	
	static 
	{
		String os = System.getProperty("os.name");
		local = !"Linux".equals(os);
		StringBuilder builder = new StringBuilder();
		builder.append(local ? "local" : "server").append(".").append("ruan").append(".");
		prefix = builder.toString();
	}

}
